import requests
from bs4 import BeautifulSoup


def show_web_message():
    # 目标 URL
    url = "https://example.com"

    # 发送 HTTP GET 请求
    response = requests.get(url)

    # 检查请求是否成功
    if response.status_code == 200:
        print("请求成功！")

        # 解析 HTML 内容
        soup = BeautifulSoup(response.text, "html.parser")

        # 抓取网页标题
        title = soup.title.string
        print(f"网页标题: {title}")

        # 抓取所有链接
        links = soup.find_all("a")
        print("网页中的所有链接：")
        for link in links:
            href = link.get("href")
            text = link.text.strip()
            print(f"{text}: {href}")
    else:
        print(f"请求失败，状态码: {response.status_code}")
